//package com.fang.config;
//
//import com.fang.task.DspTestTask;
//import com.fang.task.DspTestTask2;
//import com.fang.task.DspTestTask3;
//import org.quartz.*;
//import org.springframework.beans.BeansException;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.ApplicationContextAware;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.scheduling.quartz.CronTriggerFactoryBean;
//import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean;
//import org.springframework.scheduling.quartz.SchedulerFactoryBean;
//
//@Configuration
//public class QuartzConfig {
////    private ApplicationContext applicationContext;
////    @Override
////    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
////        this.applicationContext = applicationContext;
////    }
//
////    @Bean(name = "testjobdetail")
////    public MethodInvokingJobDetailFactoryBean detailFactoryBean(DspTestTask dspTestTask) {
////        MethodInvokingJobDetailFactoryBean methodInvokingJobDetailFactoryBean = new MethodInvokingJobDetailFactoryBean();
////        methodInvokingJobDetailFactoryBean.setTargetObject(dspTestTask);
////        methodInvokingJobDetailFactoryBean.setTargetMethod("test");
////
////        return methodInvokingJobDetailFactoryBean;
////    }
////
////    @Bean(name = "testtrigger")
////    public CronTriggerFactoryBean cronTriggerFactoryBean(JobDetail testjobdetail) {
////        CronTriggerFactoryBean cronTriggerFactoryBean = new CronTriggerFactoryBean();
////        cronTriggerFactoryBean.setJobDetail(testjobdetail);
////        cronTriggerFactoryBean.setCronExpression("0/2 * * * * ?");
////
////        return cronTriggerFactoryBean;
////    }
////
////
////    @Bean
////    public SchedulerFactoryBean schedulerFactoryBean(JobDetail testjobdetail,Trigger testtrigger) {
////        SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
////        schedulerFactoryBean.setJobDetails(testjobdetail);
////        schedulerFactoryBean.setTriggers(testtrigger);
////        schedulerFactoryBean.start();
////        return schedulerFactoryBean;
////    }
//
//
//    /**
//     * 2
//     */
//    @Bean
//    public JobDetail jobDetail() {
//        //JobBuilder()是protected
////        new JobBuilder().build()
//
//        //storeDurably()???不加报错???
//        JobDetail jobDetail = JobBuilder.newJob(DspTestTask.class).withIdentity("jobDetail").storeDurably().build();
//        return jobDetail;
//    }
//    @Bean
//    public Trigger trigger() {
//        //TriggerBuilder是private
////        Trigger trigger = new TriggerBuilder<Trigger>().build();
//
//        TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger();
//        //protected
////        CronScheduleBuilder cronScheduleBuilder = new CronScheduleBuilder("0/2 * * * * ?");
//
//        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule("0/2 * * * * ?");
//        CronTrigger cronTrigger = triggerBuilder.withSchedule(cronScheduleBuilder).forJob("jobDetail").build();
//        return cronTrigger;
//    }
//
//
//    @Bean
//    public JobDetail jobDetail2() {
//        //JobBuilder()是protected
////        new JobBuilder().build()
//
//        JobDetail jobDetail = JobBuilder.newJob(DspTestTask2.class).withIdentity("jobDetail2").storeDurably().build();
//        return jobDetail;
//    }
//    @Bean
//    public Trigger trigger2() {
//        //TriggerBuilder是private
////        Trigger trigger = new TriggerBuilder<Trigger>().build();
//
//        TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger();
//        //protected
////        CronScheduleBuilder cronScheduleBuilder = new CronScheduleBuilder("0/2 * * * * ?");
//
//        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule("0/2 * * * * ?");
//        CronTrigger cronTrigger = triggerBuilder.withSchedule(cronScheduleBuilder).forJob("jobDetail2").build();
//        return cronTrigger;
//    }
//
//    /**
//     * 测试不impl Job 并同一个task内不同的method 有不同的 cron
//     *
//     * @param jobDetail
//     * @param trigger
//     * @return
//     */
//    @Bean(name = "task3")
//    //JobDetail 是接口
//    public MethodInvokingJobDetailFactoryBean task3(DspTestTask3 dspTestTask3) {
//        MethodInvokingJobDetailFactoryBean methodInvokingJobDetailFactoryBean = new MethodInvokingJobDetailFactoryBean();
//        methodInvokingJobDetailFactoryBean.setTargetObject(dspTestTask3);
//        methodInvokingJobDetailFactoryBean.setTargetMethod("test");
//
//        return methodInvokingJobDetailFactoryBean;
//    }
//    @Bean
//    public CronTriggerFactoryBean task3Trigger(JobDetail task3) {
//        CronTriggerFactoryBean cronTriggerFactoryBean = new CronTriggerFactoryBean();
//        cronTriggerFactoryBean.setCronExpression("0/3 * * * * ?");
//        cronTriggerFactoryBean.setJobDetail(task3);
//
//        return cronTriggerFactoryBean;
//    }
//    @Bean(name = "task3test2")
//    //JobDetail 是接口
//    public MethodInvokingJobDetailFactoryBean task3Test2(DspTestTask3 dspTestTask3) {
//        MethodInvokingJobDetailFactoryBean methodInvokingJobDetailFactoryBean = new MethodInvokingJobDetailFactoryBean();
//        methodInvokingJobDetailFactoryBean.setTargetObject(dspTestTask3);
//        methodInvokingJobDetailFactoryBean.setTargetMethod("test2");
//
//        return methodInvokingJobDetailFactoryBean;
//    }
//    @Bean
//    public CronTriggerFactoryBean task3Test2Trigger(JobDetail task3test2) {
//        CronTriggerFactoryBean cronTriggerFactoryBean = new CronTriggerFactoryBean();
//        cronTriggerFactoryBean.setCronExpression("0/1 * * * * ?");
//        cronTriggerFactoryBean.setJobDetail(task3test2);
//
//        return cronTriggerFactoryBean;
//    }
//
//
//    @Bean
//    //需要Trigger,CronTriggerFactoryBean它不应该算Trigger呐,
//    public SchedulerFactoryBean schedulerFactoryBean(JobDetail[] jobDetail,Trigger[] trigger) {
//        SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
//        //它是可以接受数组的,一旦jobDetail给了唯一标识,trigger又绑定了jobDetail,为啥还要setJobDetail呢
//        // 注掉它,会报错,说jobDetail不存在
//        schedulerFactoryBean.setJobDetails(jobDetail);
//        //它也是可以接受数组的
//        schedulerFactoryBean.setTriggers(trigger);
//
//        schedulerFactoryBean.start();
//
//        return schedulerFactoryBean;
//    }
//
//
//}
